package com.atguigu.mybatis.mapper;

import com.atguigu.mybatis.beans.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by Smexy on 2023/3/22
 * <p>
 * sql语句不需要去维护升级，为了开发的方便，直接写在java文件中
 * <p>
 * 是什么sql，就用什么注解即可。
 */
public interface EmployeeMapper2
{
    @Select(" select * from employee where id = #{ id }")
    Employee getEmpById(Integer id);

    @Insert("        insert into employee(last_name,gender,email) values(#{lastName},#{gender},#{email})  ")
    void insertEmployee(Employee e);

    @Update("  update employee set last_name = #{lastName} , gender = #{gender} ,email = #{email} " +
        "        where id = #{id} ")
    void updateEmployee(Employee e);

    @Delete("             delete from employee where id = #{ id } ")
    void deleteEmpById(Integer id);

    @Select(" select * from employee ")
    List<Employee> getAll();
}
